include(['PClass'], 
		
function(){
	
	declare('renderers.Renderer');

	Renderer = PClass.create({
		name       : '',
		rendering  : false,
		init   : function(name){
			this.name = name || 'Renderer ' + (Renderer.count++);;
		},
		render : function(gw){
			if( this.rendering ) return;

			this.rendering = true;
			
			var c = gw.c;
			for(var e in gw.entities ){
				var entity = gw.entities[e];
				if(entity && !(typeof(entity) == 'function' )){
					c.save();
					var pass = 0;
					try{
						pass = this.renderObject( gw, entity );
					}finally{
						if( !pass ){
							console.log("Removing [" + e + "]");
							gw.entities[e] = null;	
						}
					}
					c.restore();
				}
			}
			this.rendering = false;
		},
		renderObject : function(gw, obj){
			
		}
	});
	Renderer.count = 1;
	
})
